//
//  SDMoreViewController.m
//  Sydeny
//
//  Created by Rainbow on 7/23/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "SDMoreViewController.h"
#import "FavoriteShopsTableViewController.h"
#import "SearchShopsTableViewController.h"
#import "CommonShopsTableViewController.h"
#import "LoginViewController.h"
#import "CurrentViewShopsTableViewController.h"
#import "SDDealHouseTableViewController.h"
#import "SDBuyCarTableViewController.h"
#import "SDAbroadTableViewController.h"
#import "SDSettingViewController.h"
#import "ServiceHelper.h"

@implementation SDMoreViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIImageView *logoView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo.png"]] autorelease];
    logoView.frame = CGRectMake(0, 0, 94, 29);
    self.navigationItem.titleView = logoView;
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)tapOnSearchBtn:(id)sender {
    SearchShopsTableViewController *searchShopsTableViewController = [[SearchShopsTableViewController alloc] initWithNibName:@"SDShopsTableViewController" bundle:nil];
    [self.navigationController pushViewController:searchShopsTableViewController animated:YES];
    [searchShopsTableViewController release];
    return;
}

//- (IBAction)tapOnNearistBtn:(id)sender {
//    NSMutableDictionary *params = [[[NSMutableDictionary alloc] initWithCapacity:0] autorelease];
//    [params setObject:@"1" forKey:@"page"];
//    [params setObject:@"10" forKey:@"limit"];
//    if ([CacheData sharedData].latitude != nil && [CacheData sharedData].latitude != nil) {
//        
//        [params setObject:[CacheData sharedData].latitude forKey:@"latitude"];
//        [params setObject:[CacheData sharedData].longitude forKey:@"longtitude"];
//    }
//    CommonShopsTableViewController *commonShopsTableViewController = [[CommonShopsTableViewController alloc] initWithRequsetParams:params withTitle:@"附近推荐" RequestType:SydenyRequestGetShops];
//    commonShopsTableViewController.loadFinish = YES;
//    [self.navigationController pushViewController:commonShopsTableViewController animated:YES];
//    [commonShopsTableViewController release];
//
//}

- (IBAction)tapOnRankBtn:(id)sender {
    
    NSMutableDictionary *params = [[[NSMutableDictionary alloc] initWithCapacity:0] autorelease];
    [params setObject:@"1" forKey:@"page"];
    [params setObject:[NSString stringWithFormat:@"%d",PER_PAGE_NUMBER] forKey:@"limit"];
    CommonShopsTableViewController *commonShopsTableViewController = [[CommonShopsTableViewController alloc] initWithRequsetParams:params withTitle:@"排行榜" RequestType:SydenyRequestGetRank];
    [self.navigationController pushViewController:commonShopsTableViewController animated:YES];
    [commonShopsTableViewController release];
}

- (IBAction)tapOnCurrentBtn:(id)sender {
    CurrentViewShopsTableViewController *currentViewShopsTableViewController = [[CurrentViewShopsTableViewController alloc] initWithNibName:@"SDShopsTableViewController" bundle:nil];
    [self.navigationController pushViewController:currentViewShopsTableViewController animated:YES];
    [currentViewShopsTableViewController release];
}

- (IBAction)tapOnFavoriteBtn:(id)sender {
    FavoriteShopsTableViewController *favoriteShopsTableViewController = [[FavoriteShopsTableViewController alloc] initWithNibName:@"SDShopsTableViewController" bundle:nil];
    [self.navigationController pushViewController:favoriteShopsTableViewController animated:YES];
    [favoriteShopsTableViewController release];
}

- (IBAction)tapOnLoginBtn:(id)sender {
    LoginViewController *loginViewController = [[LoginViewController alloc] init];
    UINavigationController *tempNavigationController = [[UINavigationController alloc] initWithRootViewController:loginViewController];
    [self.navigationController presentModalViewController:tempNavigationController animated:YES];
    [tempNavigationController release];
    [loginViewController release];
}

- (IBAction)tapOnSettingBtn:(id)sender {
    SDSettingViewController *settingViewController = [[SDSettingViewController alloc] init];
    [self.navigationController pushViewController:settingViewController animated:YES];
    [settingViewController release];
}

- (IBAction)tapOnDealHouse:(id)sender {
    NSMutableDictionary *params = [[[NSMutableDictionary alloc] init] autorelease];
    
    [params setObject:@"1" forKey:@"page"];
    [params setObject:[NSString stringWithFormat:@"%d",PER_PAGE_NUMBER] forKey:@"limit"];
    [params setObject:@"4" forKey:@"type"];
    
    SDDealHouseTableViewController *dealHouseTableViewController = [[SDDealHouseTableViewController alloc] initWithRequsetParams:params withTitle:@"房屋买卖" RequestType:SydenyRequestGetShops];
    [self.navigationController pushViewController:dealHouseTableViewController animated:YES];
    [dealHouseTableViewController release];
}

- (IBAction)tapOnBuyCar:(id)sender {
    
    NSMutableDictionary *params = [[[NSMutableDictionary alloc] init] autorelease];
    
    [params setObject:@"1" forKey:@"page"];
    [params setObject:[NSString stringWithFormat:@"%d",PER_PAGE_NUMBER] forKey:@"limit"];
    [params setObject:@"5" forKey:@"type"];
    
    SDBuyCarTableViewController *buyCarTableViewController = [[SDBuyCarTableViewController alloc] initWithRequsetParams:params withTitle:@"购车指南" RequestType:SydenyRequestGetShops];
    [self.navigationController pushViewController:buyCarTableViewController animated:YES];
    [buyCarTableViewController release];
    
}

- (IBAction)tapOnAbroad:(id)sender {
    NSMutableDictionary *params = [[[NSMutableDictionary alloc] init] autorelease];
    
    [params setObject:@"1" forKey:@"page"];
    [params setObject:[NSString stringWithFormat:@"%d",PER_PAGE_NUMBER] forKey:@"limit"];
    [params setObject:@"6" forKey:@"type"];
    
    SDAbroadTableViewController *abroadTableViewController = [[SDAbroadTableViewController alloc] initWithRequsetParams:params withTitle:@"留学移民" RequestType:SydenyRequestGetShops];
    [self.navigationController pushViewController:abroadTableViewController animated:YES];
    [abroadTableViewController release];
    
}
@end
